//
//  RYDingdanListViewController.swift
//  SheYangBigData
//
//  Created by 宋海胜 on 2021/1/25.
//  Copyright © 2021 叁拾叁. All rights reserved.
//



import UIKit


class RYDingdanListViewController: SYBaseViewController {
    
    // MARK: - properties
    var id: Int!
    
    
    
    fileprivate var firvc: RYDingdanTotalViewController!
     
    fileprivate var secvc: RYDaizhifuListViewController!
    
    fileprivate var thirvc: RYRenyangzhongListViewController!
    
    fileprivate var fourvc: RYPeisongzhongListViewController!
    
    fileprivate var fivevc: RYYiwanchengListViewController!
    
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.navigationBar.isHidden = false
        self.tabBarController?.tabBar.isHidden = true
    }
    
    
    // MARK: - life cycle
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        firvc = RYDingdanTotalViewController()
        firvc.currentVC = self
        firvc.view.backgroundColor = .white
        secvc = RYDaizhifuListViewController()
        secvc.currentVC = self
        secvc.view.backgroundColor = .white
        thirvc = RYRenyangzhongListViewController()
        thirvc.currentVC = self
        thirvc.view.backgroundColor = .white
        fourvc = RYPeisongzhongListViewController()
        fourvc.currentVC = self
        fourvc.view.backgroundColor = .white
        fivevc = RYYiwanchengListViewController()
        fivevc.currentVC = self
        fivevc.view.backgroundColor = .white
        reloadLists()
        creatPageView()
        
//        NotificationCenter.default.addObserver(self, selector: #selector(refreshPunchVC), name: .Noti_SkipToLoginView, object: nil)
        self.title = "我的认养"
    }
    
    
    // MARK: - public methods
    public func refreshItemsNum() {
        
    }
    
    // MARK: - event response
    @objc func refreshPunchVC() {

    }
    
    // MARK: - private methods
    func creatPageView() {
        let p1: EScrollPageItemBaseView = firvc.bgView
        let p2: EScrollPageItemBaseView = secvc.bgView
        let p3: EScrollPageItemBaseView = thirvc.bgView
        let p4: EScrollPageItemBaseView = fourvc.bgView
        let p5: EScrollPageItemBaseView = fivevc.bgView
        let param = EScrollPageParam()
        param.segmentParam.lineColor = UIColor(hex: 0x367FF6)
        param.segmentParam.textSelectedColor = 0x367FF6
        param.segmentParam.textColor = 0x656565
        param.headerHeight = 40.autoWidth()
        let pageView: EScrollPageView = EScrollPageView(frame: CGRect(x: 0, y: NAV_HEIGHT, width: SCREEN_WIDTH, height: SCREEN_HEIGHT - NAV_HEIGHT), dataViews: [p1, p2, p3, p4, p5], setParam: param)
        self.view.addSubview(pageView)
    }
    
    fileprivate func loadDataSuccessed() {
        
    }

    fileprivate func reloadLists() {
        // 不是依次执行，只是全部完成后给通知
//        HUDUtil.showBlackIndiView()
        let queue = DispatchQueue(label: "getlist")
        let group  = DispatchGroup()
        queue.async(group: group, execute: {
            group.enter()

//            self.getDetailData(id: self.id) {[weak self] model in
//                if let `self` = self {
//                                        DispatchQueue.main.async {
////                                            weakSelf.refreshItemsNum()
//                                        }
//                                        group.leave()
//                }
//            }
        })

        group.notify(queue: queue) {
            DispatchQueue.main.async {
                HUDUtil.hideHud()
                self.loadDataSuccessed()
            }
        }
    }

        
    
}



